<?php
/*-----------------------------------------
MAGIC - User System Framework

This class serves as the bootloader by which the rest of the usersystem's framework is loaded. 

@Version: 2009.05.28	v0.7.8
@Author: Carl
@Licence: LGPL -  http://www.gnu.org/licenses/lgpl.html
@Copyright (c) thybag.co.uk 2009
-----------------------------------------*/


//Import configuation options
if(!isset($config['magic_path']))
	require_once('magic_config.php');	//If alternate config has been loaded do not attempt to load our's as well	
	
define('PATH', $config['magic_path']);	//Because the inernet explodes if this goes missing

Reg::set($config);

//Check system has been installed
if(Reg::get('magic_path') == ''){		
	header ('location: install/installer.php');		
	die();
}	

session_start();	//session							
ob_start(array('ob_gzhandler',4));//compress

/*
  If a call is made to a class that does not already exist, attempt to load it from a classes directory.
*/
function __autoload($class) {		
	
	// Create a full path to the class we want
	$class = str_replace('/', '', $class); 	
	$classpath = PATH . 'Class/' . $class . '.class.php';
	
	//Attempt to include the file.
	if (file_exists($classpath)) {					
		require_once $classpath;	
	}else{
		//This cannot be recovered from. Throw exception
		$e = new MagicException($classpath);
		$e->classLoadError();
	}
}
